<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="com.eos.data.datacontext.UserObject" %>
<%@ page import="commonj.sdo.DataObject"%>
<%@ page import="org.gocom.components.coframe.rights.dataset.CapUser"%>
<%@ page import="java.math.BigDecimal"%>	
<%@ page import="com.eos.engine.component.ILogicComponent"%>
<%@ page import="com.primeton.ext.engine.component.LogicComponentFactory"%>
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): houfy
  - Date: 2016-10-25 14:23:02
  - Description:
-->
<head>
	<%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp"%>
	<title>督办管理详细</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	 <%
        // 来源操作flg
		String actionFlg = "";
		if(request.getParameter("actionFlg")!=null){
			actionFlg = (String)request.getParameter("actionFlg");
		}
		// 借款ID
		String superviseid = "";
		if(request.getParameter("superviseid")!=null){
			superviseid = (String)request.getParameter("superviseid");
		}
    	
    	//===== BEG 添加流程实例ID为传入参数，用于查询实体数据  add 2014-12-09 houfy
    	//流程实例ID
 	 	String processInstId = "";
		if(request.getParameter("processInstId")!=null){
			processInstId = (String)request.getParameter("processInstId");
		}
		
		//流程实例工作项ID
 	 	String workitemid = "";
		if(request.getParameter("workitemid")!=null){
			workitemid = (String)request.getParameter("workitemid");
		}
		
		//节点名称
		String activitydefid = "";
		if(request.getParameter("activitydefid")!=null) {
			activitydefid = (String)request.getParameter("activitydefid");
		}else{
			activitydefid = "null";
		}
		//打开方式
		String webType = "";
		if(request.getParameter("webType")!=null) {
			webType = (String)request.getParameter("webType");
		}
 	 	//===== END 添加流程实例ID为传入参数，用于查询实体数据  add 2014-12-09 houfy
	%>
</head>
<body>
	<div id="showbtnArea" class="nui-toolbar" style="padding:0px;" borderStyle="border:0;">
			<table width="100%">
		    	<tr>
		        	<td style="text-align:right;">
		          		<a id="okBtn" class="nui-button" iconCls="icon-save" onclick="onOk">保存</a>
		        	</td>
		      	</tr>
		    </table>
		</div>
		<div id="editSuperviseForm" style="padding-top:10px;">
		<!-- 督办ID -->
  		<input id="superviseid" class="nui-hidden" name="Supervise.superviseid"/>
		
    	<table style="width:100%;height:100%;table-layout:fixed;" class="nui-form-table">
      		<tr>
      			<th class="nui-form-label"><font color="red">*</font>&nbsp;督办批次编号：</th>
        		<td>
          			<input id="supervisecode" class="nui-textbox nui-form-input" name="Supervise.supervisecode" required="true" requiredErrorText="督办批次编号不能为空！"/>
        		</td>
        		<th class="nui-form-label"><font color="red">*</font>&nbsp;督办事项编号：</th>
        		<td>
          			<input id="itemnum" class="nui-textbox nui-form-input" style="width:100%;" name="Supervise.itemnum"  required="true" requiredErrorText="督办事项编号不能为空！"/>
        		</td>
      		</tr>
      		<tr class="odd">
      			<th class="nui-form-label">督办来源：</th>
        		<td>
        			<input id="supervisefrom" class="nui-textbox nui-form-input" name="Supervise.supervisefrom" textName="Supervise.supervisefrom"  style="width: 100%;"/>
			       
        		</td>
        		<th class="nui-form-label">督办接收日期：</th>
        		<td>
        			<input id="receivedate" name="Supervise.receivedate" class="nui-datepicker" style="width:100%;" allowInput="false"/>
			       
        		</td>
        		
      		</tr>
      		<tr>
      			<th class="nui-form-label">督办标题：</th>
        		<td>
          			<input id="supervisename" class="nui-textbox nui-form-input" name="Supervise.supervisename" "/>
        		</td>
      			<th class="nui-form-label"></th>
        		<td>
        		</td>
      		</tr>
      		<tr class="odd">
        		<th class="nui-form-label"><font color="red">*</font>&nbsp;督办内容：</th>
        		<td  colspan="3">
          			<input id="superviseinfo" class="nui-textarea nui-form-input" name="Supervise.superviseinfo" vtype="rangeChar:0,1300" rangeCharErrorText="内容长度不能超过1300！" required="true" requiredErrorText="督办内容不能为空！"/>
          		</td>
      		</tr>
      		<tr>
        		<th class="nui-form-label">最迟反馈日期：</th>
        		<td>
        			<input id="latestdate" name="Supervise.latestdate" class="nui-datepicker" style="width:100%;" allowInput="false"/>
			       
        		</td>
        		<th class="nui-form-label">督办反馈部门：</th>
        		<td>
        			<input  id="superviseunit" class="nui-treeselect nui-form-input" name="Supervise.superviseunit" textName="Supervise.orgname"
			       			url="com.shendong.mis.common.queryOrgOrganization.biz.ext" multiSelect="false"  valueFromSelect="false"
        					dataField="datas" textField="orgname" valueField="orgid" parentField="parentorgid"   onbeforenodeselect="beforenodeselect" 
       						showRadioButton="true" showFolderCheckBox="false"
    				/>
        		</td>
      		</tr>
      		<tr class="odd">
      		<th class="nui-form-label">备注：</th>
        		<td  colspan="3">
          			<input id="remark" class="nui-textarea nui-form-input" name="Supervise.remark" vtype="rangeChar:0,1300" rangeCharErrorText="备注长度不能超过1300！"/>
          			<!-- 附件 -->
          			<input id="fileids" class="nui-hidden" name="Supervise.fileids"/>
        		</td>
        	</tr>
        	<tr id="inputArea">
      			<th class="nui-form-label">实际督办单位：</th>
        		<td>
			        <input  id="actualunit" class="nui-treeselect nui-form-input" name="Supervise.actualunit" textName="Supervise.actualunitname"
			       			url="com.shendong.mis.common.queryOrgOrganization.biz.ext" multiSelect="false"  valueFromSelect="false"
        					dataField="datas" textField="orgname" valueField="orgid" parentField="parentorgid"   onbeforenodeselect="beforenodeselect" 
       						showRadioButton="true" showFolderCheckBox="false"
    				/>
        		</td>
        		<th class="nui-form-label">督办反馈人：</th>
        		<td>
          			<input id="actualempid" class="nui-buttonedit nui-form-input" emptyText="请选择..." style="width:100%;" name="Supervise.actualempid" textName="Supervise.empname"  allowInput="false" required="true" requiredErrorText="督办反馈人不能为空！" onbuttonclick="userData"/>
        		</td>
        		
      		</tr>
      		<tr class="odd"  id="inputArea1">
      			<th class="nui-form-label">督办反馈：</th>
    			<td  colspan="3">
      				<input id="supervisefeedback" class="nui-textarea nui-form-input" name="Supervise.supervisefeedback" vtype="rangeChar:0,1300" rangeCharErrorText="督办反馈长度不能超过1300！"/>
      			</td>	
      		</tr>
      		<tr>
      			<th class="nui-form-label">反馈时间：</th>
        		<td>
        			<input id="feedbackdate" name="Supervise.feedbackdate" class="nui-datepicker" style="width:100%;" allowInput="false"/> 
        		</td>
        	</tr>
    	</table>
		<div style="width:100%;padding:2px 0px 0px 0px;">
			<div class="nui-toolbar" style="border-bottom:0;">
	        	<table style="width:100%;">
	            	<tr>
			            <td style="width:50%;">
			                <a class="nui-button" id="uploadify">上传</a>
			            	<a id="deleteFile" class="nui-button" onclick="removeFile()" style="margin-left: 85px; width:60px;">删除</a>
			            </td>
				    	<th align="left">附件</th>
		            </tr>
		        </table>
	    	</div>
	    </div>
    	<div class="nui-fit" style="width:100%;min-height: 83px;height: 85px;">
  			<div id="attachmentDatagrid" class="nui-datagrid" style="width:100%;height:100%" sizeList="[5,10,20,50]"  
  				idField="fileid" dataField="cmFiles" url="com.austar.cm.common.queryUplodeFileListByIds.biz.ext" 
		    	allowResize="false" showPager="false" showReloadButton="false" totalField="total" multiSelect="true">
		    	<div property="columns">
		        	<div field="fileid" visible="false">ID</div>
		        	<div field="filepath" visible="false">路径</div>
          			<div name="checkcolumn" type="checkcolumn" headerAlign="center" width="10px" align="center"></div>
		        	<div type="indexcolumn" headerAlign="center" width="20px" align="center">序号</div>
		        	<div field="uploadname" headerAlign="center" allowSort="true" renderer="renderOnfileName">文件名称</div>
		    	</div>
			</div>
	    </div>
	</div>
	<script type="text/javascript">
    	nui.parse();
    	var form = new nui.Form("#editSuperviseForm");
    	var grid = nui.get("attachmentDatagrid");
    	var actionFlg="<%=actionFlg%>";
    	var superviseid="<%=superviseid%>";
    	var uploadFlg = true;
    	var processInstId = "<%=processInstId %>" ;
	    var workitemid ="<%=workitemid%>";
	    var activitydefid = "<%=activitydefid %>";
 		var webType = "<%=webType %>";
    	 
    	if(actionFlg=="add" || actionFlg=="processStart")
    	{
		    
    	}else if(actionFlg=="process"){
    		//从流程业务关系表中查询关系数据
    		if (processInstId!=null && processInstId!= ""){
    			var processJson =  nui.encode({processInstId:processInstId});
    			$.ajax({
			        url:"com.atozsoft.wf.processOperate.queryProcessBusinessRelationByID.biz.ext",
			        type:'POST',
			        data:processJson,
			        cache:false,
			        async:false,// 禁止异步加载
			        contentType:'text/json',
			        success:function(text){
			        	superviseid = text.pBusiness.keyvalue;
			        },
	                error: function () {
	                	nui.alert("数据异常！", "提示");
	                }
		      	});
    		} 
	
    		var pbJson  = nui.encode({superviseid:superviseid,processInstId:processInstId});
    		if(superviseid!=null && superviseid!= ''){
    			pbJson  = nui.encode({superviseid:superviseid});
    		}
    		
    		//各种监听事件
		    $.ajax({
			     url:"com.shendong.mis.supervise.querySupervisebyID.biz.ext",
			     type:'POST',
			     data:pbJson,
		         contentType:'text/json',
		 	     async:false,
		 	     cache:false,
		 	     success:function(text){
		 	       form.setData(text);
                   form.setChanged(false);
                   nui.get("superviseid").setValue(text.Supervise.superviseid);
                   nui.get("status").setValue(text.Supervise.status);
                   
		 	     }
		   });	
    	}else{
    		var json = nui.encode({superviseid:superviseid});
		     //各种监听事件
			$.ajax({
			     url:"com.shendong.mis.supervise.querySupervisebyID.biz.ext",
			     type:'POST',
			     data:json,
		         contentType:'text/json',
		 	     async:false,
		 	     cache:false,
		 	     success:function(text){
		 	       form.setData(text);
                   form.setChanged(false);
                   nui.get("superviseid").setValue(text.Supervise.superviseid);
                   nui.get("status").setValue(text.Supervise.status);
                   
		 	     }
			});	
    	}
    	
    	if(actionFlg=="process" && activitydefid=="supervise_04") actionFlg = "update";
    	//设定页面字段显示式样
    	setViewClass(actionFlg);

    	// 编辑按钮切换样式
	    function setViewClass(flg){
			if(flg=="add"){
				
			}else if(flg=="update"){
				nui.get("supervisecode").disable();
				nui.get("itemnum").disable();
				nui.get("supervisefrom").disable();
				nui.get("receivedate").disable();
				nui.get("supervisename").disable();
				nui.get("superviseinfo").disable();
				nui.get("latestdate").disable();
				nui.get("remark").disable();
				nui.get("superviseunit").disable();
				
				nui.get("actualunit").enable();
				nui.get("actualempid").enable();
				nui.get("supervisefeedback").enable();
				nui.get("feedbackdate").enable();
				nui.get("superviseunit").enable();
				
				document.getElementById("inputArea").style.backgroundColor = "#ffcc99";
				document.getElementById("inputArea1").style.backgroundColor = "#ffcc99";
			}else if(flg=="view"){
				nui.get("supervisecode").disable();
				nui.get("itemnum").disable();
				nui.get("supervisefrom").disable();
				nui.get("receivedate").disable();
				nui.get("supervisename").disable();
				nui.get("superviseinfo").disable();
				nui.get("latestdate").disable();
				nui.get("remark").disable();
				nui.get("superviseunit").disable();
				nui.get("okBtn").disable();
				nui.get("actualunit").disable();
				nui.get("actualempid").disable();
				nui.get("supervisefeedback").disable();
				nui.get("feedbackdate").disable();
				nui.get("superviseunit").disable();
				
			}else{
				//按钮隐藏
				$("#showbtnArea").hide();
				
				nui.get("supervisecode").disable();
				nui.get("itemnum").disable();
				nui.get("supervisefrom").disable();
				nui.get("receivedate").disable();
				nui.get("supervisename").disable();
				nui.get("superviseinfo").disable();
				nui.get("latestdate").disable();
				nui.get("remark").disable();
				nui.get("okBtn").disable();
				nui.get("actualunit").disable();
				nui.get("actualempid").disable();
				nui.get("supervisefeedback").disable();
				nui.get("feedbackdate").disable();
				nui.get("superviseunit").disable();
			}
	      
	    }
	    
    	//PROCESS BEG ============== 流程操作代码 ==============
		
    	// 设置不可编辑样式
        function noEdit(){
		    setViewClass();
        }
	    
	   // 流程执行父页面调用接口
       parent["infoFrame"] = window;
       // 父页面调用的字段控制操作
       // 01 显示 工时（workhours）字段
	   //传递控制参数
       var parentWorkType = "2345";
       
       function onParentCallCheck(){
       		var str = "false";
	        return str;
       	}
       
        // 父页面调用的保存操作，同意操作打开之前执行
	    function onParentCallOk(){
	        // 设定保存返回值   
        	var resultStr = "";
	        return resultStr;
	    }
	    
	    // 工作项确认同意后调用的操作
	    function onParentCallAfterOk(){
	    }
	    
	    // 流程执行父页面调用接口
        var checkSet = "";
       
	    //获取节点选择窗口的筛选值
	    function getCheckSet(){
        	if(activitydefid=="supervise_02"){
        		return "13";
        	}else if(activitydefid=="supervise_03"){
        		return "13";
        	}else if(activitydefid=="supervise_06"){
        		return "13";
        	}else{
        		return checkSet;
        	}
        }
    	
	    // 流程完成后，打开页面查看时调用的操作
	    function onParentCallAfterStop(){
	    	
	    }
	    
	    // 父页面调用的打印操作
	    function onParentCallPrint(){
	    	//parent.printPage();
	    }
	    
	    // 更新流程业务关系表
	    function updatePBRelation(){
	    }
	    
	    // 流程与业务参数传递函数
	    function onParentEditParams(){
	    
	    }
	    
		// 等待提示
		function loading(){
			nui.mask({el: document.body,cls: 'mini-mask-loading',html: '处理中...'});
		}
		
		// 结束等待提示
	    function endLoading(){
	    	nui.unmask(document.body);
    	}
	    
	  	//PROCESS END ============== 流程操作代码 ==============
    	

    	// 保存按钮
	    function onOk(){
	    	saveData();
	    }
	    
        // 保存表单数据
		function saveData() {
			var form = new nui.Form("#editSuperviseForm");
	        form.setChanged(false);
	        //保存
	        var urlStr = "com.shendong.mis.supervise.saveSupervise.biz.ext";
	        form.validate();
	        if(form.isValid()==false) return;
	
	        var data = form.getData(false,true);
	        var json = nui.encode(data);
			//alert(json);
	        $.ajax({
	          url:urlStr,
	          type:'POST',
	          data:json,
	          cache:false,
	          contentType:'text/json',
	          success:function(text){
	            var returnJson = nui.decode(text);
	            
	            if(returnJson.resultStr == "success"){
	              nui.get("superviseid").setValue(text.Supervise.superviseid);
	              nui.alert("保存成功！");
	              
	            }else{
	              nui.alert("保存失败", "系统提示", function(action){
	                if(action == "ok" || action == "close"){
	                  //CloseWindow("saveFailed");
	                }
	              
	               });
	             }
	           }
	         });
	    }
	  	
		
		// 选择督办反馈人
  	    function userData(){
	    	nui.open({
                url: "<%=request.getContextPath()%>/mis/orgUser/selectEmployee.jsp",
                title: "用户",
                width: 870,
                height: 550,
                onload: function () {
                	var iframe = this.getIFrameEl();
			        iframe.contentWindow.SetData({multiSelect:'false'});
                },
                ondestroy: function (action) {
              	 	if(action=="ok"){
              	 		var iframe = this.getIFrameEl();
                        var data = iframe.contentWindow.GetData();
                        data = nui.clone(data);    //必须克隆返回值
                        // 主管所领导赋值
                        nui.get("actualempid").setValue(data.empid);
                        nui.get("actualempid").setText(data.username);     	 	
                    }
                }
            });
	    }
	    
	    //写完treeSelect必须加这个函数，要不选不到
    	function beforenodeselect(e) {
            //禁止选中父节点
            if (e.isLeaf == false) e.cancel = true;
        }
    </script>
</body>
</html>